//初始化导航
var nav2Data = {};
	
	$.ajax({
		url: 'menu/initList',   // 路径
		type: 'post',
		data: {},
		success: function(data){
			nav2Data = data;
		},
		error: function(data){
			
		}
	})
	
	var bodyWidth = window.screen.width;
	var w = $(window).width();
	$(window).resize(function(){
          w = $(window).width()   ;
          if(w>1000){
        	  nav2Show();
		}else{
			$(".headercon2").hide();
		}
    });
	
	// 当屏幕分辨率大于1000是 pc端导航添加hover事件
	if(bodyWidth>1000 && w>1000){
		nav2Show();
	}else{
		$(".headercon2").hide();
	}
	
	
	// 当屏幕分辨率小于1000时 添加移动端点击菜单方法
	if(w<1000 || bodyWidth<1000){
		$(".navIcon").click(function(e){
            $(this).show();
            e.stopPropagation();// 阻止冒泡
        });
        $(document).click(function(){
            $(".headerList").hide();
            $(".headeBg").hide();
         
        })
	}
	
	$(".topBtn").on("click", function() {
	     $('body,html').animate({
	      scrollTop: 0
	     }, 500);
	     return false;
	});
	    
	$(".navIcon").click(function(){
		$(".headeBg").toggle();
		$(".headerList").toggle();
	})
	// 显示子菜单方法
	function nav2Show(){
		$(".navList .navListLi").hover(function(){
			var navIndex = $(this).index();
		    var curmenuid = $(this).find("a").attr("curmenuid"); 
		    //如果是导航第一个首页或者最后一个客户办公室时   二级菜单隐藏
		    var lastLength = parseInt($(".navList .navListLi").length)-1;
			if(navIndex == 0 || navIndex == lastLength){
				$(".headercon2").hide();
			}else{
				$(".headercon2").show();
			}
			if(nav2Data!=null && nav2Data[0]!=undefined && nav2Data[0].children.length>0){
			    for(var i=0; i<nav2Data[0].children.length; i++){
					if(curmenuid == nav2Data[0].children[i].id){
						var nav2 = nav2Data[0].children[i].children ;
						$("#navList2").empty();
						var html ="";
						
						if(nav2 != null && nav2 != "" && nav2 != "undefined"){
							for(var j=0; j<nav2.length; j++){
								html += "<li class=\"navListLi2\"><a href=\""+nav2[j].url+"\">"+nav2[j].name+"</a></li>";
							}
							$("#navList2").append(html);
							$(".headercon2").show();
						}else{
							$(".headercon2").hide();
						}
						
					}
				}
			}
			
		},function(){
			$(".headercon2").hover(function(){
				$(".headercon2").show();
			},function(){
				$(".headercon2").hide();
			})
		})
	}
	
	$(function() {
			var $window = $(window),
				win_height_padded = $window.height() * 1.1,
				isTouch = Modernizr.touch;
			if (isTouch) {
				$('.visible').addClass('animated');
			}
			$window.on('scroll', visible);

			function visible() {
				var scrolled = $window.scrollTop(),
					win_height_padded = $window.height() * 1.1;
				$(".visible:not(.animated)").each(function() {
					var $this = $(this),
						offsetTop = $this.offset().top;
					if (scrolled + win_height_padded > offsetTop) {
						if ($this.data('timeout')) {
							window.setTimeout(function() {
								$this.addClass('animated ' + $this.data('animation'));
							}, parseInt($this.data('timeout'), 10));
						} else {
							$this.addClass('animated ' + $this.data('animation'));
						}
					}
				});
				$(".visible.animated").each(function(index) {
					var $this = $(this),
						offsetTop = $this.offset().top;
					if (scrolled + win_height_padded < offsetTop) {
						$(this).removeClass('animated fadeInUp fadeInLeft fadeInRight swing zoomIn zoomInDown pulse bounceIn');
					}
				});
			}
			visible();
		});
